import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import { close, start } from '../utils/nporgress';

const routes:Array<RouteRecordRaw> = [
    {
        path:"/LoginView",
        name:"LoginView",
        component:()=>import("../views/LoginView.vue") 
    },
    {
        path:"/",
        name:"HomeView",
        component:()=>import("../views/HomeView.vue"),
        redirect:"/AboutView",
        children:[
            {
                path:"/AboutView",
                name:"AboutView",
                component:()=>import("../views/AboutView.vue")
            },
            {
                path:"/HocksView",
                name:"HocksView",
                component:()=>import("../views/HocksView.vue")
            },
        ]
    },
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

router.beforeEach((to, from, next)=>{
    start();
    console.log(to, from);
    console.log(to.path);
    // if(to.path != '/LoginView'){
    //     return next('/LoginView')
    // }
    next();
})

router.afterEach(()=>{
    close();
})

export default router